package com.ad.pet.app.account.order;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.ad.pet.DaggerMainActivityCompent;
import com.ad.pet.MainActivity;
import com.ad.pet.MainActivityCompent;
import com.ad.pet.R;
import com.ad.pet.app.account.order.fragment.OrderFragment;
import com.ad.pet.app.account.order.fragment.OrderStatusFragment;
import com.ad.pet.app.main.adapter.HomeViewPagerAdapter;
import com.ad.pet.common.data.injector.HasComponent;
import com.ad.pet.common.structure.mvp.BasePresenter;
import com.ad.pet.common.structure.ui.activity.AppToolbarActivity;
import com.ad.pet.constant.Constant;

import java.util.ArrayList;

import butterknife.BindView;

/**
 * Created by SEELE on 2019/1/28.
 */

public class OrderStatusActivity extends AppToolbarActivity implements HasComponent<MainActivityCompent> {
    @BindView(R.id.tab_layout)
    TabLayout mTabLayout;
    @BindView(R.id.viewpager)
    ViewPager mViewpager;


    private ArrayList<Fragment> mFragmentList;
    private ArrayList<String> mList_title;
    private HomeViewPagerAdapter mHomeViewPagerAdapter;
    private MainActivityCompent mMainComponent;
    private String mType;
    private String mTitle;

    @Override
    protected void init(Bundle savedInstanceState) {
        super.init(savedInstanceState);

        mToolbar.setTitle(mTitle);
        mStatusLayoutManager.showContent();
    }

    @Override
    protected int contentLayout() {
        return R.layout.activity_order_status;
    }

    @Override
    protected void clickRetry(View v) {

    }

    @Override
    protected void initViews() {

        mType = getIntent().getStringExtra(Constant.STATUS);
        mTitle = getIntent().getStringExtra(Constant.NAME);
        mFragmentList = new ArrayList<>();
        mList_title = new ArrayList<>();
        mList_title.add(getString(R.string.all));
//        mList_title.add(getString(R.string.unpaid));
//        mList_title.add(getString(R.string.waiting_share_frieds));
//        mList_title.add(getString(R.string.processing));
//        mList_title.add(getString(R.string.shiping));
//        mList_title.add(getString(R.string.competed));
//        mList_title.add(getString(R.string.abnormal));


        mFragmentList.add(OrderStatusFragment.newInstance(mType));
        mFragmentList.add(OrderFragment.newInstance("1"));
//        mFragmentList.add(PacektInfoFragment.newInstance("2"));
//        mFragmentList.add(OrderStatusFragment.newInstance("1"));
//        mFragmentList.add(PacektInfoFragment.newInstance("2"));
//        mFragmentList.add(PacektInfoFragment.newInstance("3"));
//        mFragmentList.add(OrderStatusFragment.newInstance("4"));


        mHomeViewPagerAdapter = new HomeViewPagerAdapter(getSupportFragmentManager());
        mHomeViewPagerAdapter.setData(mFragmentList, mList_title);
        mViewpager.setAdapter(mHomeViewPagerAdapter);
//        ViewpagerLineUtil.setTabWidth(mTabLayout, 25);
        mTabLayout.setupWithViewPager(mViewpager);//
//        mViewpager.setCurrentItem(mType);

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initEvents() {

    }

    @Override
    public void initInject() {
        mMainComponent = DaggerMainActivityCompent.builder().applicationComponent(getApplicationComponent()).activityModule(getActivityModule()).build();
        mMainComponent.inject(this);
    }

    @Override
    protected BasePresenter getPresenter() {
        return null;
    }

    @Override
    public MainActivityCompent getComponent() {
        return mMainComponent;
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == Activity.RESULT_OK) {
            switch (requestCode) {


                case MainActivity.REQUEST_GO_MALL:
                    setResult(RESULT_OK, data);

                    finish();
                    break;


            }
        }

    }
//
//    @Override
//    public void showLoading() {
//
//    }
//
//    @Override
//    public void hideLoading() {
//
//    }
//
//    @Override
//    public void error(String msg) {
//
//    }
//
//
//
//    @Override
//    public void compressComplete(File file) {
//        Logger.e("file："+file.exists());
//        mConfirmReciveDialog.onSetFiles(file);
//    }
//
//    @Override
//    public void photoCallback(String path) {
//
//    }


}
